package com.example.arithmeticleetcode.leetcode.dec;

import java.util.Arrays;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-12-29 09:17
 **/
public class Demo29 {

    public static void main(String[] args) {
        System.out.println(maxArea(5,4, new int[]{3,1}, new int[]{1}));
        System.out.println(Math.pow(10, 5));
        System.out.println(Integer.MAX_VALUE > 755332975);
        System.out.println(Integer.MAX_VALUE);

    }

    public static int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {
        Arrays.sort(horizontalCuts);
        Arrays.sort(verticalCuts);
        long hDiffMax = horizontalCuts[0] - 0;
        for (int i = 1; i < horizontalCuts.length; i++) {
            long diff = horizontalCuts[i] - horizontalCuts[i - 1];
            if (hDiffMax < diff) {
                hDiffMax = diff;
            }
        }
        long hLastDiff = h - horizontalCuts[horizontalCuts.length - 1];
        hDiffMax =  hLastDiff > hDiffMax ? hLastDiff : hDiffMax;

        long wDiffMax = verticalCuts[0] - 0;
        for (int i = 1; i < verticalCuts.length; i++) {
            long diff = verticalCuts[i] - verticalCuts[i - 1];
            if (wDiffMax < diff) {
                wDiffMax = diff;
            }
        }
        long zLastDiff = w - verticalCuts[verticalCuts.length - 1];
        wDiffMax =  zLastDiff > wDiffMax ? zLastDiff : wDiffMax;
        return (int)((hDiffMax*wDiffMax)%(Math.pow(10,9)+7));
    }
}

